package ginutil

import (
	"gitee.com/xuyiping_admin/pkg/apierr"
	"gitee.com/xuyiping_admin/pkg/jsonpb"
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/golang/protobuf/proto"
)

func JSONResp(c *gin.Context, pb proto.Message) {
	bs, err := jsonpb.MarshalBytes(pb)
	if err != nil {
		apierr.AbortInternalError(c, http.StatusInternalServerError, err)
		return
	}
	c.Data(http.StatusOK, "application/json", bs)
}
